/*********************************************************

    Konami 053260 PCM/ADPCM Sound Chip

*********************************************************/

#pragma once

#ifndef __K053260_H__
#define __K053260_H__


#define LOG 0

#define BASE_SHIFT	16

typedef struct _k053260_channel k053260_channel;
struct _k053260_channel
{
	UINT32		rate;
	UINT32		size;
	UINT32		start;
	UINT32		bank;
	UINT32		volume;
	int					play;
	UINT32		pan;
	UINT32		pos;
	int					loop;
	int					ppcm; /* packed PCM ( 4 bit signed ) */
	int					ppcm_data;
};


class CK053260 : public CBaseSoundDevice {
	private:
		int								mode;
		int								regs[0x30];
		UINT8					*rom;
		int								rom_size;
		UINT32					*delta_table;
		k053260_channel		channels[4];
	
	private:
		void InitDeltaTable( int rate, int clock );
		void CheckBounds( int channel );
	public:
		void Reset();
		int  Buffer(short** buf, int length);
		void Init(CMixer* mix, unsigned int clock);
		void Write(UINT64 offset, UINT8 data);
		UINT8 Read(UINT64 offset);
		void SetRom(int slot, CMemory* rom);


};

/*
typedef struct _k053260_interface k053260_interface;
struct _k053260_interface {
	const char *rgnoverride;
	timer_fired_func irq;			// called on SH1 complete cycle ( clock / 32 )
};
*/

//WRITE8_DEVICE_HANDLER( k053260_w );
//READ8_DEVICE_HANDLER( k053260_r );

//DEVICE_GET_INFO( k053260 );
//#define SOUND_K053260 DEVICE_GET_INFO_NAME( k053260 )

#endif /* __K053260_H__ */
